import React, { Component } from "react";
import { Icon, message } from "antd";
import { connect } from "dva";

import styles from "./index.less";

@connect(stores => ({
  channelData: stores.channelModel
}))
class ChannelDetail extends Component {
  back = () => {
    this.props.history.push("/messageCenter/messageManager/msgSourceManage");
  };

  // static componentWillUnmount() {
  //   sessionStorage.setItem("msgSourceRecord", "{}");
  // }

  render() {
    // owners = [{ name: "" }],
    const {
      // channelData: { msgSourceRecord },
      location
    } = this.props;
    let data = location.search.split("=");
    if (data[1]) {
      data = JSON.parse(decodeURIComponent(data[1]));
    } else {
      // data = JSON.parse(JSON.stringify(msgSourceRecord));
      message.warning("无数据，请返回列表重新操作");
      return <span />;
    }
    window.console.log(data);
    return (
      <div className={styles.root}>
        <div className={styles.top}>
          <div className={styles.textContainer}>
            <div className={`${styles.text} ${styles.title}`}>消息源详情</div>
            <div className={`${styles.text} ${styles.close}`}>
              <Icon onClick={this.back} type="close" />
            </div>
          </div>
          <div className={styles.textContainer}>
            <div className={styles.text}>
              <span className={styles.name}>创建/更新人：</span>
              <span className={styles.value}>{data.userName}</span>
            </div>
          </div>
          <div className={styles.textContainer}>
            <div className={styles.text}>
              <span className={styles.name}>状态：</span>
              <span className={styles.value}>
                {data.isEnabled === "Y" ? "正常" : "禁用"}
              </span>
            </div>
          </div>
          <div className={styles.textContainer}>
            <div className={styles.text}>
              <span className={styles.name}>消息源编码：</span>
              <span className={styles.value}>{data.sourceCode}</span>
            </div>
            <div className={styles.text}>
              <span className={styles.name}>消息源名称：</span>
              <span className={styles.value}>{data.sourceName}</span>
            </div>
            <div className={styles.text}>
              <span className={styles.name}>消息源类型：</span>
              <span className={styles.value}>{data.sourceType}</span>
            </div>
          </div>
          <div className={styles.textContainer}>
            <div className={styles.text}>
              <span className={styles.name}>场景编码：</span>
              <span className={styles.value}>{data.sceneCode}</span>
            </div>
            <div className={styles.text}>
              <span className={styles.name}>场景名称：</span>
              <span className={styles.value}>{data.sceneName}</span>
            </div>
            <div className={styles.text}>
              <span className={styles.name}>场景描述：</span>
              <span className={styles.value}>{data.sceneDescription}</span>
            </div>
          </div>
          <div className={styles.textContainer}>
            <div className={styles.text}>
              <span className={styles.name}>是否自带渠道：</span>
              <span className={styles.value}>
                {data.haveChannel === "Y" ? "是" : "否"}
              </span>
            </div>
            <div className={styles.text}>
              <span className={styles.name}>是否自带消息模板：</span>
              <span className={styles.value}>
                {data.haveTemplate === "Y" ? "是" : "否"}
              </span>
            </div>
            <div className={styles.text}>
              <span className={styles.name}>是否自带消息接收组：</span>
              <span className={styles.value}>
                {data.haveGroup === "Y" ? "是" : "否"}
              </span>
            </div>
          </div>
        </div>
      </div>
    );
  }
}

export default ChannelDetail;
